﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
using MuaChungDTO;
namespace MuaChungDAO
{
    public class BangGiaDealDAO : DataProvider
    {
        public BangGiaDealDAO()
        {

        }
        public ArrayList getDsBangGiaDeal()
        {
            connect();
            string query = "SELECT * FROM BangGiaDeal";
            adapter = new SqlDataAdapter(query, connection);
            DataSet dataset = new DataSet();
            adapter.Fill(dataset);
            ArrayList arr = ConvertDataSetToArrayList(dataset);

            return arr;
        }


        public ArrayList getBangGiaTheoID(string dealId)/// hoi thua.. can sua lai
        {
            connect();
            string query = "select * from BangGiaDeal where DealID = " + dealId;
            adapter = new SqlDataAdapter(query, connection);
            DataSet dataset = new DataSet();
            adapter.Fill(dataset);
            ArrayList arr = ConvertDataSetToArrayList(dataset);

            return arr;
        }
        protected override object GetDataFromDataRow(DataTable dt, int i)
        {
            BangGiaDealDTO bg = new BangGiaDealDTO();
            bg.BangGiaDealID = int.Parse(dt.Rows[i]["BangGiaDeal"].ToString());
            bg.DealId = int.Parse(dt.Rows[i]["DealId"].ToString());
            bg.HinhAnh = dt.Rows[i]["HinhAnh"].ToString();     
            return (object)bg;
        }
    }
}
